Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/radio/component/ConfigState.kt cd1ebd1ec1470b3968fb7aedfc69975b1b0be5f3 (cd1ebd1e) Text, 2.61 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.feature.settings.radio.component

Tff7b72import T7ee787androidx.compose.runtime.Composable
Tff7b72import T7ee787androidx.compose.runtime.getValue
Tff7b72import T7ee787androidx.compose.runtime.mutableStateOf
Tff7b72import T7ee787androidx.compose.runtime.saveable.Saver
Tff7b72import T7ee787androidx.compose.runtime.saveable.rememberSaveable
Tff7b72import T7ee787androidx.compose.runtime.setValue
Tff7b72import T7ee787com.squareup.wire.Message

T8b949e/**
* A state holder for managing config data within a Composable.
*
* This class encapsulates the common logic for handling editable state that is derived from an initial value. It tracks
* whether the current value has been modified ("dirty"), and provides simple methods to save the changes or reset to
* the initial state.
*
* @param T The type of the data being managed, typically a Wire message.
* @property initialValue The original, unmodified value of the config data.
*/
Tff7b72class T56d364ConfigStateTff7b72<Te6edf3T Tb4b4b4: Te6edf3MessageTff7b72<Te6edf3TTb4b4b4, Tff7b72*Tff7b72>Tff7b72>Tb4b4b4(Tff7b72private Tff7b72val Te6edf3initialValueTb4b4b4: Te6edf3TTb4b4b4) Tb4b4b4{
Tff7b72var Te6edf3value Tff7b72by Te6edf3mutableStateOfTb4b4b4(Te6edf3initialValueTb4b4b4)

Tff7b72val Te6edf3isDirtyTb4b4b4: Tffa657Boolean
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3value Tff7b72!Tff7b72= Te6edf3initialValue

Tff7b72fun Td2a8ffresetTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3value Tff7b72= Te6edf3initialValue
Tb4b4b4}

Tff7b72companion Tff7b72object Tb4b4b4{
Tff7b72fun Tff7b72<Te6edf3T Tb4b4b4: Te6edf3Message<Te6edf3TTb4b4b4, *Tff7b72>> Td2a8ffsaverTb4b4b4(Te6edf3initialValueTb4b4b4: Te6edf3TTb4b4b4)Tb4b4b4: Te6edf3SaverTff7b72<Te6edf3ConfigStateTff7b72<Te6edf3TTff7b72>Tb4b4b4, Te6edf3ByteArrayTff7b72> Tff7b72= Te6edf3SaverTb4b4b4(
Te6edf3save Tff7b72= Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3valueTb4b4b4.Te6edf3adapterTb4b4b4.Te6edf3encodeTb4b4b4(Tffa657itTb4b4b4.Te6edf3valueTb4b4b4) Tb4b4b4}Tb4b4b4,
Te6edf3restore Tff7b72= Tb4b4b4{ Te6edf3ConfigStateTb4b4b4(Te6edf3initialValueTb4b4b4)Tb4b4b4.Te6edf3apply Tb4b4b4{ Te6edf3value Tff7b72= Te6edf3initialValueTb4b4b4.Te6edf3adapterTb4b4b4.Te6edf3decodeTb4b4b4(Tffa657itTb4b4b4) Tb4b4b4} Tb4b4b4}Tb4b4b4,
Tb4b4b4)
Tb4b4b4}
Tb4b4b4}

T8b949e/**
* Creates and remembers a [ConfigState] instance, correctly handling process death and recomposition. When the
* `initialValue` changes, the config state will be reset.
*
* @param initialValue The initial value to populate the config with. The config will be reset if this value changes
* across recompositions.
*/
Tf0883e@Composable
Tff7b72fun Tff7b72<Te6edf3T Tb4b4b4: Te6edf3Message<Te6edf3TTb4b4b4, *Tff7b72>> Td2a8ffrememberConfigStateTb4b4b4(Te6edf3initialValueTb4b4b4: Te6edf3TTb4b4b4)Tb4b4b4: Te6edf3ConfigStateTff7b72<Te6edf3TTff7b72> Tff7b72=
Te6edf3rememberSaveableTb4b4b4(Te6edf3initialValueTb4b4b4, Te6edf3saver Tff7b72= Te6edf3ConfigStateTb4b4b4.Te6edf3saverTb4b4b4(Te6edf3initialValueTb4b4b4)Tb4b4b4) Tb4b4b4{ Te6edf3ConfigStateTb4b4b4(Te6edf3initialValueTb4b4b4) Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.04s